home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / source.exe / POSIX / BSDPSX / UTIMES.C < prev    next >
C/C++ Source or Header  |  1992-10-25  |  657b  |  39 lines

  1. #if 0
  2. # include <stdio.h>
  3. #endif
  4. #include <sys/types.h>
  5. #include <time.h>
  6. #include <utime.h>
  7.  
  8. struct timeval {
  9.     long    tv_sec;        /* seconds */
  10.     long    tv_usec;    /* and microseconds */
  11. };
  12.  
  13. int
  14. #if __STDC__
  15. utimes (const char *file, struct timeval *tvp)
  16. #else
  17. utimes (file, tvp)
  18. const char *file;
  19. struct timeval tvp [];
  20. #endif
  21. {
  22. #ifdef _POSIX_SOURCE
  23.     struct utimbuf ut;
  24. #else
  25.     struct utimebuf ut;
  26. #endif
  27.  
  28.     if (tvp == NULL) {
  29.         ut.actime = ut.modtime = time(NULL);
  30.     } else {
  31.         ut.actime = tvp[0].tv_sec;
  32.         ut.modtime = tvp[1].tv_sec;
  33.     }
  34. #if 0
  35.     printf("time %ld %ld\n", ut.actime, ut.modtime);
  36. #endif
  37.     return utime(file, &ut);
  38. }
  39.